package cc.config;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;

import springfox.documentation.builders.PathSelectors;

import springfox.documentation.builders.RequestHandlerSelectors;

import springfox.documentation.service.ApiInfo;

import springfox.documentation.service.Contact;

import springfox.documentation.spi.DocumentationType;

import springfox.documentation.spring.web.plugins.Docket;



/**

 * Swagger2配置类

 *

 * @author BEE

 * @date 2021/10/18 8:34

 */

@Configuration

public class SwaggerConfig {



    @Bean

    public Docket createRestApi(){

        return new Docket(DocumentationType.SWAGGER_2)

                .apiInfo(aipInfo())

                .select()

                //配置swagger扫描路径

                .apis(RequestHandlerSelectors.basePackage("cc.web"))

                .paths(PathSelectors.any())

                .build();

    }



    /**

     * 构建api文档的详细信息函数，注意控制器controler包路径的扫描。

     * @return

     */

    private ApiInfo aipInfo(){

        return new ApiInfoBuilder()

                .title("智能系统设计与开发课程接口文档")

                .contact(new Contact("我不是晨曦","","workforbee@outlook.com"))

                .version("1.0")

                .description("这个是项目的描述以及文档的描述")

                .build();

    }

}


